﻿using DALDemo1.testDataSetTableAdapters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DALDemo1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Demo1 demo1 = new Demo1();
            demo1.test2();
            demo1.test3();
            demo1.test();

            Console.ReadLine();

        }
    }


    class Demo1
    {

        public void test()
        {
            CourseTableAdapter adapter = new CourseTableAdapter();
            testDataSet.CourseDataTable courseDataTable = adapter.GetData();
            var x = from a in courseDataTable select a;
            foreach(var c in x)
            {
                Console.WriteLine("{0},{1},{2}",c.CourseID,c.Credits,c.Title);
            }

        }

        public void test2()
        {
            CourseTableAdapter adapter = new CourseTableAdapter();
            testDataSet.CourseDataTable courseDataTable = adapter.GetData();
            var x = from a in courseDataTable where a.CourseID == 1 select a;
            foreach (var c in x)
            {
                c.Credits = 100;
                adapter.Update(c);
            }

            

        }

        public void test3()
        {
            CourseTableAdapter adapter = new CourseTableAdapter();
            adapter.Insert("心理学", 45);
        }


    }
}
